package com.job.Gai_Yian.Homework0707;

/**
 * @author Gai_Yian
 * @version 1.0
 * @since 2022-07-09 11:38:26
 */
public class Example7 {
    String name;
    int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age<18||age>60){
            System.out.println("年龄不符合，本次赋值失败！");
            return;
        }
        this.age = age;
    }

    public void showSelf(String name){
        System.out.println("大声对"+name+"说：我是"+this.name+"\t我的年龄"+age);
    }

    public static void main(String[] args){
        Example7 emp=new Example7();
        emp.name="David";
        emp.age=20;
        emp.showSelf("老王");
    }
}
